import java.io.IOException;
import java.nio.MappedByteBuffer;
import java.util.ArrayList;

final public class IndexTreeBinaryReader<T> extends TreeBinaryReaderWriter<T> {

    IndexTreeBinaryReader(MappedByteBuffer mbb) {
        super(mbb);
    }

    @Override
    public ArrayList<Object> parse1() {
        try {
            int left = mbb.getInt();
            int right = mbb.getInt();
            int parent = mbb.getInt();
            byte[] key = readByteArray(mbb);
            data.add(id);
            data.add((left != 0) ? left : null);
            data.add((right != 0) ? right : null);
            data.add((parent != 0) ? parent : null);
            data.add(new WordIndex(key));
        } catch (IOException e) {
            throw new UnsupportedOperationException(e);
        }
        return data;
    }
}
